home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / TextServices.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  11.7 KB  |  561 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        TextServices.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__TEXTSERVICES__') = 'UNDEFINED' THEN
  18. __TEXTSERVICES__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__EVENTS__') = 'UNDEFINED' THEN
  27.     include 'Events.a'
  28.     ENDIF
  29. ;        include 'Quickdraw.a'                                        ;
  30. ;            include 'MixedMode.a'                                    ;
  31. ;            include 'QuickdrawText.a'                                ;
  32. ;        include 'OSUtils.a'                                        ;
  33. ;            include 'Memory.a'                                        ;
  34.  
  35.     IF &TYPE('__MENUS__') = 'UNDEFINED' THEN
  36.     include 'Menus.a'
  37.     ENDIF
  38.  
  39.     IF &TYPE('__APPLEEVENTS__') = 'UNDEFINED' THEN
  40.     include 'AppleEvents.a'
  41.     ENDIF
  42. ;        include 'Errors.a'                                            ;
  43. ;        include 'EPPC.a'                                            ;
  44. ;            include 'PPCToolbox.a'                                    ;
  45. ;                include 'AppleTalk.a'                                ;
  46. ;            include 'Processes.a'                                    ;
  47. ;                include 'Files.a'                                    ;
  48. ;        include 'Notification.a'                                    ;
  49.  
  50.     IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
  51.     include 'Components.a'
  52.     ENDIF
  53.  
  54. kTSMVersion                        EQU        $200                ; Version of the Text Services Manager is 2.0  
  55. kTextService                    EQU        'tsvc'                ; component type for the component description 
  56. kInputMethodService                EQU        'inpm'                ; component subtype for the component description 
  57. ; Component Flags in ComponentDescription 
  58. bTakeActiveEvent                EQU        15                    ; bit set if the component takes active event 
  59. bHandleAERecording                EQU        16                    ; bit set if the component takes care of recording Apple Events <new in vers2.0> 
  60. bScriptMask                        EQU        $00007F00            ; bit 8 - 14 
  61. bLanguageMask                    EQU        $000000FF            ; bit 0 - 7  
  62. bScriptLanguageMask                EQU        bScriptMask + bLanguageMask ; bit 0 - 14  
  63.  
  64. ; Hilite styles 
  65. kCaretPosition                    EQU        1                    ; specify caret position 
  66. kRawText                        EQU        2                    ; specify range of raw text 
  67. kSelectedRawText                EQU        3                    ; specify range of selected raw text 
  68. kConvertedText                    EQU        4                    ; specify range of converted text 
  69. kSelectedConvertedText            EQU        5                    ; specify range of selected converted text 
  70.  
  71. ; Apple Event constants 
  72. ; Event class 
  73. kTextServiceClass                EQU        kTextService
  74. ; event ID 
  75. kUpdateActiveInputArea            EQU        'updt'                ; update the active Inline area 
  76. kPos2Offset                        EQU        'p2st'                ; converting global coordinates to char position 
  77. kOffset2Pos                        EQU        'st2p'                ; converting char position to global coordinates 
  78. kShowHideInputWindow            EQU        'shiw'                ; show or hide the input window 
  79. ; Event keywords 
  80. keyAETSMDocumentRefcon            EQU        'refc'                ; TSM document refcon, typeLongInteger 
  81. ; Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  82. ;    typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  83. ;    AERegistry.h 
  84. keyAEServerInstance                EQU        'srvi'                ; component instance 
  85. keyAETheData                    EQU        'kdat'                ; typeText 
  86. keyAEFixLength                    EQU        'fixl'                ; fix len ?? 
  87. keyAEHiliteRange                EQU        'hrng'                ; hilite range array 
  88. keyAEUpdateRange                EQU        'udng'                ; update range array 
  89. keyAEClauseOffsets                EQU        'clau'                ; Clause Offsets array 
  90. keyAECurrentPoint                EQU        'cpos'                ; current point 
  91. keyAEDragging                    EQU        'bool'                ; dragging falg 
  92. keyAEOffset                        EQU        'ofst'                ; offset 
  93. keyAERegionClass                EQU        'rgnc'                ; region class 
  94. keyAEPoint                        EQU        'gpos'                ; current point 
  95. keyAEBufferSize                    EQU        'buff'                ; buffer size to get the text 
  96. keyAEMoveView                    EQU        'mvvw'                ; move view flag 
  97. keyAELength                        EQU        'leng'                ; length 
  98. keyAENextBody                    EQU        'nxbd'                ; next or previous body 
  99. ; optional keywords for Offset2Pos (Info about the active input area) 
  100. keyAETextLineHeight                EQU        'ktlh'                ; typeShortInteger 
  101. keyAETextLineAscent                EQU        'ktas'                ; typeShortInteger 
  102. ; optional keywords for Pos2Offset 
  103. keyAELeftSide                    EQU        'klef'                ; type Boolean 
  104. ; optional keywords for kShowHideInputWindow 
  105. keyAEShowHideInputWindow        EQU        'shiw'                ; type Boolean 
  106. ; for PinRange  
  107. keyAEPinRange                    EQU        'pnrg'
  108. ; Desc type ... 
  109. typeComponentInstance            EQU        'cmpi'                ; server instance 
  110. typeTextRangeArray                EQU        'tray'                ; text range array 
  111. typeOffsetArray                    EQU        'ofay'                ; offset array 
  112. typeText                        EQU        'TEXT'                ; Plain text 
  113. typeTextRange                    EQU        'txrn'
  114.  
  115. ; Desc type constants 
  116. kTSMOutsideOfBody                EQU        1
  117. kTSMInsideOfBody                EQU        2
  118. kTSMInsideOfActiveInputArea        EQU        3
  119.  
  120. kNextBody                        EQU        1
  121. kPreviousBody                    EQU        2
  122.  
  123. ; typeTextRange         'txrn' 
  124. TextRange                 RECORD    0
  125. fStart                     ds.l    1
  126. fEnd                     ds.l    1
  127. fHiliteStyle             ds.w    1
  128. sizeof                     EQU    10
  129.                         ENDR
  130.  
  131. ; typeTextRangeArray    'txra' 
  132. TextRangeArray             RECORD    0
  133. fNumOfRanges             ds.w    1                                    ; specify the size of the fRange array 
  134. fRange                     ds        TextRange                            ; when fNumOfRanges > 1, the size of this array has to be calculated 
  135. sizeof                     EQU    12
  136.                         ENDR
  137.  
  138. ; typeOffsetArray        'offa' 
  139. OffsetArray             RECORD    0
  140. fNumOfOffsets             ds.w    1                                    ; specify the size of the fOffset array 
  141. fOffset                     ds.l    1                                    ; when fNumOfOffsets > 1, the size of this array has to be calculated 
  142. sizeof                     EQU    6
  143.                         ENDR
  144.  
  145. ; Text Service Info List 
  146. TextServiceInfo         RECORD    0
  147. fComponent                 ds.l    1
  148. fItemName                 ds.l    64
  149. sizeof                     EQU    260
  150.                         ENDR
  151.  
  152. TextServiceList         RECORD    0
  153. fTextServiceCount         ds.w    1                                    ; number of entries in the 'fServices' array 
  154. fServices                 ds        TextServiceInfo                    ; Note: array of 'TextServiceInfo' records follows 
  155. sizeof                     EQU    262
  156.                         ENDR
  157.  
  158. ScriptLanguageRecord     RECORD    0
  159. fScript                     ds.w    1
  160. fLanguage                 ds.w    1
  161. sizeof                     EQU    4
  162.                         ENDR
  163.  
  164. ScriptLanguageSupport     RECORD    0
  165. fScriptLanguageCount     ds.w    1                                    ; number of entries in the 'fScriptLanguageArray' array 
  166. fScriptLanguageArray     ds        ScriptLanguageRecord                ; Note: array of 'ScriptLanguageRecord' records follows 
  167. sizeof                     EQU    6
  168.                         ENDR
  169.  
  170.  
  171. ; Low level routines which are dispatched directly to the Component Manager 
  172. kCMGetScriptLangSupport            EQU        $0001                ; Component Manager call selector 1 
  173. kCMInitiateTextService            EQU        $0002                ; Component Manager call selector 2 
  174. kCMTerminateTextService            EQU        $0003                ; Component Manager call selector 3 
  175. kCMActivateTextService            EQU        $0004                ; Component Manager call selector 4 
  176. kCMDeactivateTextService        EQU        $0005                ; Component Manager call selector 5 
  177. kCMTextServiceEvent                EQU        $0006                ; Component Manager call selector 6 
  178. kCMGetTextServiceMenu            EQU        $0007                ; Component Manager call selector 7 
  179. kCMTextServiceMenuSelect        EQU        $0008                ; Component Manager call selector 8 
  180. kCMFixTextService                EQU        $0009                ; Component Manager call selector 9 
  181. kCMSetTextServiceCursor            EQU        $000A                ; Component Manager call selector 10 
  182. kCMHidePaletteWindows            EQU        $000B                ; Component Manager call selector 11 
  183.  
  184. ; High level TSM routines 
  185.     IF GENERATING68K THEN
  186.         Macro
  187.         _NewTSMDocument
  188.             moveq    #0,d0
  189.             dc.w     $AA54
  190.         EndM
  191.     ELSE
  192.         IMPORT    NewTSMDocument
  193.     ENDIF
  194.  
  195.     IF GENERATING68K THEN
  196.         Macro
  197.         _DeleteTSMDocument
  198.             moveq    #1,d0
  199.             dc.w     $AA54
  200.         EndM
  201.     ELSE
  202.         IMPORT    DeleteTSMDocument
  203.     ENDIF
  204.  
  205.     IF GENERATING68K THEN
  206.         Macro
  207.         _ActivateTSMDocument
  208.             moveq    #2,d0
  209.             dc.w     $AA54
  210.         EndM
  211.     ELSE
  212.         IMPORT    ActivateTSMDocument
  213.     ENDIF
  214.  
  215.     IF GENERATING68K THEN
  216.         Macro
  217.         _DeactivateTSMDocument
  218.             moveq    #3,d0
  219.             dc.w     $AA54
  220.         EndM
  221.     ELSE
  222.         IMPORT    DeactivateTSMDocument
  223.     ENDIF
  224.  
  225.     IF GENERATING68K THEN
  226.         Macro
  227.         _TSMEvent
  228.             moveq    #4,d0
  229.             dc.w     $AA54
  230.         EndM
  231.     ELSE
  232.         IMPORT    TSMEvent
  233.     ENDIF
  234.  
  235.     IF GENERATING68K THEN
  236.         Macro
  237.         _TSMMenuSelect
  238.             moveq    #5,d0
  239.             dc.w     $AA54
  240.         EndM
  241.     ELSE
  242.         IMPORT    TSMMenuSelect
  243.     ENDIF
  244.  
  245.     IF GENERATING68K THEN
  246.         Macro
  247.         _SetTSMCursor
  248.             moveq    #6,d0
  249.             dc.w     $AA54
  250.         EndM
  251.     ELSE
  252.         IMPORT    SetTSMCursor
  253.     ENDIF
  254.  
  255.     IF GENERATING68K THEN
  256.         Macro
  257.         _FixTSMDocument
  258.             moveq    #7,d0
  259.             dc.w     $AA54
  260.         EndM
  261.     ELSE
  262.         IMPORT    FixTSMDocument
  263.     ENDIF
  264.  
  265.     IF GENERATING68K THEN
  266.         Macro
  267.         _GetServiceList
  268.             moveq    #8,d0
  269.             dc.w     $AA54
  270.         EndM
  271.     ELSE
  272.         IMPORT    GetServiceList
  273.     ENDIF
  274.  
  275.     IF GENERATING68K THEN
  276.         Macro
  277.         _OpenTextService
  278.             moveq    #9,d0
  279.             dc.w     $AA54
  280.         EndM
  281.     ELSE
  282.         IMPORT    OpenTextService
  283.     ENDIF
  284.  
  285.     IF GENERATING68K THEN
  286.         Macro
  287.         _CloseTextService
  288.             moveq    #10,d0
  289.             dc.w     $AA54
  290.         EndM
  291.     ELSE
  292.         IMPORT    CloseTextService
  293.     ENDIF
  294.  
  295.     IF GENERATING68K THEN
  296.         Macro
  297.         _SendAEFromTSMComponent
  298.             moveq    #11,d0
  299.             dc.w     $AA54
  300.         EndM
  301.     ELSE
  302.         IMPORT    SendAEFromTSMComponent
  303.     ENDIF
  304.  
  305.     IF GENERATING68K THEN
  306.         Macro
  307.         _InitTSMAwareApplication
  308.             moveq    #20,d0
  309.             dc.w     $AA54
  310.         EndM
  311.     ELSE
  312.         IMPORT    InitTSMAwareApplication
  313.     ENDIF
  314.  
  315.     IF GENERATING68K THEN
  316.         Macro
  317.         _CloseTSMAwareApplication
  318.             moveq    #21,d0
  319.             dc.w     $AA54
  320.         EndM
  321.     ELSE
  322.         IMPORT    CloseTSMAwareApplication
  323.     ENDIF
  324.  
  325. ; Utilities 
  326.     IF GENERATING68K THEN
  327.         Macro
  328.         _SetDefaultInputMethod
  329.             moveq    #12,d0
  330.             dc.w     $AA54
  331.         EndM
  332.     ELSE
  333.         IMPORT    SetDefaultInputMethod
  334.     ENDIF
  335.  
  336.     IF GENERATING68K THEN
  337.         Macro
  338.         _GetDefaultInputMethod
  339.             moveq    #13,d0
  340.             dc.w     $AA54
  341.         EndM
  342.     ELSE
  343.         IMPORT    GetDefaultInputMethod
  344.     ENDIF
  345.  
  346.     IF GENERATING68K THEN
  347.         Macro
  348.         _SetTextServiceLanguage
  349.             moveq    #14,d0
  350.             dc.w     $AA54
  351.         EndM
  352.     ELSE
  353.         IMPORT    SetTextServiceLanguage
  354.     ENDIF
  355.  
  356.     IF GENERATING68K THEN
  357.         Macro
  358.         _GetTextServiceLanguage
  359.             moveq    #15,d0
  360.             dc.w     $AA54
  361.         EndM
  362.     ELSE
  363.         IMPORT    GetTextServiceLanguage
  364.     ENDIF
  365.  
  366.     IF GENERATING68K THEN
  367.         Macro
  368.         _UseInputWindow
  369.             moveq    #16,d0
  370.             dc.w     $AA54
  371.         EndM
  372.     ELSE
  373.         IMPORT    UseInputWindow
  374.     ENDIF
  375.  
  376.     IF GENERATING68K THEN
  377.         Macro
  378.         _NewServiceWindow
  379.             moveq    #17,d0
  380.             dc.w     $AA54
  381.         EndM
  382.     ELSE
  383.         IMPORT    NewServiceWindow
  384.     ENDIF
  385.  
  386.     IF GENERATING68K THEN
  387.         Macro
  388.         _CloseServiceWindow
  389.             moveq    #18,d0
  390.             dc.w     $AA54
  391.         EndM
  392.     ELSE
  393.         IMPORT    CloseServiceWindow
  394.     ENDIF
  395.  
  396.     IF GENERATING68K THEN
  397.         Macro
  398.         _GetFrontServiceWindow
  399.             moveq    #19,d0
  400.             dc.w     $AA54
  401.         EndM
  402.     ELSE
  403.         IMPORT    GetFrontServiceWindow
  404.     ENDIF
  405.  
  406.     IF GENERATING68K THEN
  407.         Macro
  408.         _FindServiceWindow
  409.             moveq    #23,d0
  410.             dc.w     $AA54
  411.         EndM
  412.     ELSE
  413.         IMPORT    FindServiceWindow
  414.     ENDIF
  415.  
  416. ; Low level TSM routines 
  417.     IF GENERATING68K THEN
  418.         Macro
  419.         _GetScriptLanguageSupport
  420.             dc.w     $2F3C
  421.             dc.w     $0004
  422.             dc.w     $0001
  423.             moveq    #0,d0
  424.             dc.w     $A82A
  425.         EndM
  426.     ELSE
  427.         IMPORT    GetScriptLanguageSupport
  428.     ENDIF
  429.  
  430.     IF GENERATING68K THEN
  431.         Macro
  432.         _InitiateTextService
  433.             dc.w     $2F3C
  434.             dc.w     $0000
  435.             dc.w     $0002
  436.             moveq    #0,d0
  437.             dc.w     $A82A
  438.         EndM
  439.     ELSE
  440.         IMPORT    InitiateTextService
  441.     ENDIF
  442.  
  443.     IF GENERATING68K THEN
  444.         Macro
  445.         _TerminateTextService
  446.             dc.w     $2F3C
  447.             dc.w     $0000
  448.             dc.w     $0003
  449.             moveq    #0,d0
  450.             dc.w     $A82A
  451.         EndM
  452.     ELSE
  453.         IMPORT    TerminateTextService
  454.     ENDIF
  455.  
  456.     IF GENERATING68K THEN
  457.         Macro
  458.         _ActivateTextService
  459.             dc.w     $2F3C
  460.             dc.w     $0000
  461.             dc.w     $0004
  462.             moveq    #0,d0
  463.             dc.w     $A82A
  464.         EndM
  465.     ELSE
  466.         IMPORT    ActivateTextService
  467.     ENDIF
  468.  
  469.     IF GENERATING68K THEN
  470.         Macro
  471.         _DeactivateTextService
  472.             dc.w     $2F3C
  473.             dc.w     $0000
  474.             dc.w     $0005
  475.             moveq    #0,d0
  476.             dc.w     $A82A
  477.         EndM
  478.     ELSE
  479.         IMPORT    DeactivateTextService
  480.     ENDIF
  481.  
  482.     IF GENERATING68K THEN
  483.         Macro
  484.         _TextServiceEvent
  485.             dc.w     $2F3C
  486.             dc.w     $0006
  487.             dc.w     $0006
  488.             moveq    #0,d0
  489.             dc.w     $A82A
  490.         EndM
  491.     ELSE
  492.         IMPORT    TextServiceEvent
  493.     ENDIF
  494.  
  495.     IF GENERATING68K THEN
  496.         Macro
  497.         _GetTextServiceMenu
  498.             dc.w     $2F3C
  499.             dc.w     $0004
  500.             dc.w     $0007
  501.             moveq    #0,d0
  502.             dc.w     $A82A
  503.         EndM
  504.     ELSE
  505.         IMPORT    GetTextServiceMenu
  506.     ENDIF
  507.  
  508.     IF GENERATING68K THEN
  509.         Macro
  510.         _TextServiceMenuSelect
  511.             dc.w     $2F3C
  512.             dc.w     $0006
  513.             dc.w     $0008
  514.             moveq    #0,d0
  515.             dc.w     $A82A
  516.         EndM
  517.     ELSE
  518.         IMPORT    TextServiceMenuSelect
  519.     ENDIF
  520.  
  521.     IF GENERATING68K THEN
  522.         Macro
  523.         _FixTextService
  524.             dc.w     $2F3C
  525.             dc.w     $0000
  526.             dc.w     $0009
  527.             moveq    #0,d0
  528.             dc.w     $A82A
  529.         EndM
  530.     ELSE
  531.         IMPORT    FixTextService
  532.     ENDIF
  533.  
  534.     IF GENERATING68K THEN
  535.         Macro
  536.         _SetTextServiceCursor
  537.             dc.w     $2F3C
  538.             dc.w     $0004
  539.             dc.w     $000A
  540.             moveq    #0,d0
  541.             dc.w     $A82A
  542.         EndM
  543.     ELSE
  544.         IMPORT    SetTextServiceCursor
  545.     ENDIF
  546.  
  547.     IF GENERATING68K THEN
  548.         Macro
  549.         _HidePaletteWindows
  550.             dc.w     $2F3C
  551.             dc.w     $0000
  552.             dc.w     $000B
  553.             moveq    #0,d0
  554.             dc.w     $A82A
  555.         EndM
  556.     ELSE
  557.         IMPORT    HidePaletteWindows
  558.     ENDIF
  559.  
  560.     ENDIF ; __TEXTSERVICES__
  561.